<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'EasyDoAdmin',
    'name' => 'EasyDoAdmin',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'language' => 'zh-CN',
    'modules' => [
        'roundSwitch' => [
            'class' => 'nickdenry\grid\toggle\Module',
        ],
        'log' => [
            'class' => 'backend\modules\log\Module',
            'aliases' => [
                'Backend App' => '@backend/runtime/logs/app.log',
                'Modules Log' => '@common/runtime/logs/modulesLog.log',
                'Frontend App' => '@frontend/runtime/logs/app.log',
            ],
        ],
    ],
    'components' => [
        'i18n' => [
            'translations' => [
                'rbac-admin' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@mdm/admin/messages',
                ],
            ],
        ],
        'request' => [
            'csrfParam' => '_csrf-EasyDoAdmin',
        ],
        'user' => [
            'identityClass' => 'backend\models\User',
            'enableAutoLogin' => false, //自动登陆
            'authTimeout'     => 3600, //1小时未操作退出登录
            'identityCookie' => ['name' => 'EasyDoAdminCookie', 'httpOnly' => true],
            'on afterLogin' => ['backend\models\User','afterLogin']
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'EasyDoAdminSession',
            'class' => 'yii\web\DbSession',
            'timeout'=>86400,//session 有效期
            'sessionTable' => 'admin_user_session',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager', // 或者使用  'yii\rbac\DbManager'
            "defaultRoles" => ["guest"],
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
        'assetManager'=>[
            'appendTimestamp' => true,//添加文件时间戳
            'bundles'=>[
                'mdm\admin\AutocompleteAsset' => [
                    'depends' => [
                        'backend\assets\JqueryMigrate',
                    ],
                ],
            ],
        ],
    ],
    'as access' => [
        'class' => 'mdm\admin\components\AccessControl',
        'allowActions' => array_merge(['site/*'],(YII_DEBUG?['auth/*','debug/*']:[]))
    ],
    "aliases" => [
        "@mdm/admin" => "@vendor/mdmsoft/yii2-admin",
    ],
    'params' => $params,
];
